//
//  LogisticsModel.swift
//  Pods
//
//  Created by eme on 2017/4/5.
//
//

import Foundation
import SwiftyJSON
import ModelProtocol

class LogisticsModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kLogisticsOrderidKey: String = "orderid"
    internal let kLogisticsSendtimeKey: String = "sendtime"
    internal let kLogisticsTaketimeKey: String = "taketime"
    internal let kLogisticsPdnameKey: String = "pdname"
    internal let kLogisticsKuaidiKey: String = "kuaidi"
    internal let kLogisticsOlidKey: String = "olid"
    internal let kLogisticsShippingdateKey: String = "shippingdate"
    internal let kLogisticsLogisticsnameKey: String = "logisticsname"
    internal let kLogisticsImg1Key: String = "img1"
    internal let kLogisticsLogisticscodeKey: String = "logisticscode"
    internal let kLogisticsDispatchremarkKey: String = "dispatchremark"
    internal let kLogisticsLogisticsnumberKey: String = "logisticsnumber"
    
    
    // MARK: 属性
    var orderid: String
    var sendtime: String
    var taketime: String
    var pdname: String
    var kuaidi: KuaidiModel
    var olid: Int
    var shippingdate: String
    var logisticsname: String
    var img1: String
    var logisticscode: String
    var dispatchremark: String
    var logisticsnumber: String
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        orderid = json[kLogisticsOrderidKey].stringValue
        sendtime = json[kLogisticsSendtimeKey].stringValue
        taketime = json[kLogisticsTaketimeKey].stringValue
        pdname = json[kLogisticsPdnameKey].stringValue
        kuaidi = KuaidiModel(json: json[kLogisticsKuaidiKey])!
        olid = json[kLogisticsOlidKey].intValue
        shippingdate = json[kLogisticsShippingdateKey].stringValue
        logisticsname = json[kLogisticsLogisticsnameKey].stringValue
        img1 = json[kLogisticsImg1Key].stringValue
        logisticscode = json[kLogisticsLogisticscodeKey].stringValue
        dispatchremark = json[kLogisticsDispatchremarkKey].stringValue
        logisticsnumber = json[kLogisticsLogisticsnumberKey].stringValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(orderid as AnyObject, forKey: kLogisticsOrderidKey)
    
        dictionary.updateValue(sendtime as AnyObject, forKey: kLogisticsSendtimeKey)
   
        dictionary.updateValue(taketime as AnyObject, forKey: kLogisticsTaketimeKey)
    
        dictionary.updateValue(pdname as AnyObject, forKey: kLogisticsPdnameKey)
    
        dictionary.updateValue(kuaidi.dictionaryRepresentation() as AnyObject, forKey: kLogisticsKuaidiKey)
    
        dictionary.updateValue(olid as AnyObject, forKey: kLogisticsOlidKey)
    
        dictionary.updateValue(shippingdate as AnyObject, forKey: kLogisticsShippingdateKey)
    
        dictionary.updateValue(logisticsname as AnyObject, forKey: kLogisticsLogisticsnameKey)
    
        dictionary.updateValue(img1 as AnyObject, forKey: kLogisticsImg1Key)
    
        dictionary.updateValue(logisticscode as AnyObject, forKey: kLogisticsLogisticscodeKey)
    
        dictionary.updateValue(dispatchremark as AnyObject, forKey: kLogisticsDispatchremarkKey)
    
        dictionary.updateValue(logisticsnumber as AnyObject, forKey: kLogisticsLogisticsnumberKey)
        
        return dictionary
    }
    
    
}
